package the_eleven_chapter;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetTest {

	InetAddress myIPAddress = null;
	InetAddress myServer = null;
	InetAddress[] getAllByName = null;

	public InetAddress getMyIP() {
		try {
			myIPAddress = InetAddress.getLocalHost();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return myIPAddress;
	}

	public InetAddress getServerIP() {
		try {
			myServer = InetAddress.getByName("o2o.explorati.online");
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return myServer;
	}
	
	public InetAddress[] getAllByName(){
		try {
			getAllByName = InetAddress.getAllByName("o2o.explorati.online");
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return getAllByName;
	}

	public static void main(String[] args) {
		InetTest mytool;
		mytool = new InetTest();
		System.out.println("Your host IP is: " + mytool.getMyIP());
		System.out.println("The Server IP is: " + mytool.getServerIP());
		System.out.println("getAllByName：" + mytool.getAllByName().toString());
	}
}
